package com.example.demo4.entity;

import lombok.Data;

import java.math.BigDecimal;
/**
 * 水果类
 */
@Data
public class Fruit {

    String id;//id
    String name;//水果名
    BigDecimal price;//单价
    BigDecimal weight;//重量
    BigDecimal discount;//折扣
    public  Fruit(String id,String name,BigDecimal price,BigDecimal discount){
        this.id = id;
        this.name = name;
        this.price = price;
        this.discount = discount;
    }
    public  Fruit(String name,BigDecimal weight){
        this.name = name;
        this.weight = weight;
    }

   public   BigDecimal getDiscount(){
        if(discount==null){
            return new BigDecimal(1);
        }
       return discount;
   }
}
